package com.ruoyi.mq

import com.ruoyi.back.domain.UserRecord
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

@Service
class ChangeFaceTaskManager {

    private val log: Logger = LoggerFactory.getLogger(ChangeFaceTaskManager::class.java)

    @Autowired
    private lateinit var delayQueueManager: DelayQueueManager

    /**
     * 正在执行
     */
    fun doing(userRecord: UserRecord) = userRecord.run {
        log.info("${this.requestId} 任务状态为 ${this.status} 正在执行中")
        id?.run { sendMq(this) }
    }

    /**
     * 新增任务
     */
    fun addTask(id: Long) {
        delayQueueManager.addToDelayQueue(id.toString(), 5000)
    }
    /**
     * 投递mq
     */
    fun sendMq(id: Long) {
        delayQueueManager.addToDelayQueue(id.toString(), 5000)
    }

}